package main

import (
	"fmt"
	"net"
	"os"
)

func main() {
	addr, err := net.ResolveTCPAddr("tcp4", "localhost:6060")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
	fmt.Println(addr.IP, addr.Port)

	conn, err := net.DialTCP("tcp", nil, addr)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(2)
	}
	recv := make([]byte, 1024)
	n, err := conn.Read(recv)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(3)
	}
	if n == 0 {
		conn.Close()
	}
	fmt.Println(string(recv[:n]))
}
